package com.matrix.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author 有点甜
 * @since 2025/8/10
 */
@Getter
public enum ShopTableStatusEnum {
    IDLE(0, "空闲"),
    IN_USE(1, "用餐中"),
    CLEANING_REQUIRED(2, "待清理");

    @EnumValue
    private final int code;

    @JsonValue
    private final String description;

    ShopTableStatusEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static ShopTableStatusEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ShopTableStatusEnum status : ShopTableStatusEnum.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid ShopTableStatus code: " + code);
    }
}
